<?php
	if(isset($_POST['aid']))
{
	require("includes/basic.php");
	$aid=$_POST['aid'];
	$id= split(',',$aid);
	foreach($id as $a => $b)
	{
	$activatep=mysql_query("update users set record_status='Y' where user_id=$b");
	}
}
if(isset($_POST['data']))
{
	require("includes/basic.php");
	//$did=$_POST['did'];
	//echo $_POST['data'];
	$d=$_POST['data'];
	$id= split(',',$d);
	foreach($id as $a => $b)
	{
		$deactivatep=mysql_query("update users set record_status='N' where user_id=$b");	
	}
	
}
if(isset($_POST['s']))
{
	require("includes/basic.php");
	$s=$_POST['s'];
	$sql="select * from users where LOWER(username) like LOWER('$s%')";
}
//else
//{
$sql="select * from users";
//}

include('ps_pagination.php'); 
$pager = new PS_Pagination($conn, $sql, 5, 5, "param1=valu1&param2=value2");
	
	/*
	 * Enable debugging if you want o view query errors
	*/
	$pager->setDebug(true);
	
	/*
	 * The paginate() function returns a mysql result set
	 * or false if no rows are returned by the query
	*/
	$rs = $pager->paginate();
	if(!$rs) die(mysql_error());


	$sr=1;
$class="evenrowbg";	

?>
<form id='viewusername' name="viewusername"> 

	<table width='100%' cellpadding='1' cellspacing='0' class='list' border="0">
	<tr>
		<!-- <th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Sr no.</span>
			</div>
		</th> 
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Open</span>
			</div>
		</th>-->
       <th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Edit</span>
			</div>
		</th>
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">First Name</span>
			</div>
		</th>
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Last Name</span>
			</div>
		</th>
		<th style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Mobile</span>
		</th>
		<th style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">User Type</span>
		</th>
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Customer Username</span>
			</div>
		</th>
        <th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Signature</span>
			</div>
		</th>
        <th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Created Date</span>
			</div>
		</th>
		<!--<th style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Mobile</span>
		</th>
		<th style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Address</span>
		</th>
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Customer Username</span>
			</div>
		</th>-->
		<!--<th style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Customer Password</span>
		</th>-->
		
		<th style='white-space: nowrap;'>
			<span class="link linkdisabled">Record Status</span>
		</th>
		<!--<th width='10%' style='white-space: nowrap;'>
			<span class="link">Status</span>
		</th>-->
		<th class='select'>
			
<input type='checkbox' class='checkbox' name='allCheck' id='listSelectAll'>
		</th>
	</tr>
	<?php 
	while($usertr = mysql_fetch_array($rs)) 
	{
		$uid=$usertr['user_id'];
		//$usertypeid=$usertr['usertypeid'];
		$fname=$usertr['fname'];
		$lname=$usertr['lname'];
		$mobile=$usertr['mobile'];
		$user_type=$usertr['user_type'];
		$username=$usertr['username'];
		$signature=$usertr['signature'];
		$user_created=$usertr['user_created'];
		$record_status=$usertr['record_status'];
			
		if($class=="evenrowbg")
		{
			$class="oddrowbg";
		}
		else
		{
			$class="evenrowbg";
		}
		echo "<tr class='$class' >";
		//echo "<td style='text-align:center;'>$sr</td>";
		//echo "<td style='text-align:center;'><a href='open_cat.php?open=$catid'><img src='images/open.png'/></a></td>";
		echo "<td style='text-align:center;'><a href='edit-users.php?uid=$uid'><img src='images/edit.png'/></a></td>";
	
		echo "<td>".$fname."</td><td>".$lname."</td>";
		echo "<td>".$mobile."</td><td>".$user_type."</td>";
		echo "<td>".$username."</td>";
		echo "<td>".$signature."</td>";
		echo "<td>".$user_created."</td>";
		
		
		echo "<td style='text-align:center;'>";
		if($record_status=='Y')
		{
			echo "<img src='images/multi_activate.png' alt='Active' title='Active'>";
		}
		else
		{
			echo "<img src='images/multi_deactivate.png' alt='Disabled' title='Disabled'>";
		}
		echo "</td>";
		echo "<td style='text-align:center;'><input type='checkbox' value='$uid' id='custid' name='chkName'></td>";
		$sr++;
		echo "</tr>";
		
	}
	//echo Pages("tutorials",$perpage,"view-customers.php?");	

	?>


</table>
</form>
<?php

	//Display the full navigation in one go
	 echo "<br />\n";?>
	

